#!/bin/bash

# Linux 依赖安装脚本

echo "安装 Brainfuck IDE 编译依赖..."

# 检测发行版
if [ -f /etc/os-release ]; then
    . /etc/os-release
    case $ID in
        ubuntu|debian)
            echo "检测到 Ubuntu/Debian，安装依赖..."
            sudo apt update
            sudo apt install -y build-essential cmake
            ;;
        centos|rhel|fedora)
            if [ "$ID" = "fedora" ]; then
                echo "检测到 Fedora，安装依赖..."
                sudo dnf groupinstall -y "Development Tools"
                sudo dnf install -y cmake
            else
                echo "检测到 CentOS/RHEL，安装依赖..."
                sudo yum groupinstall -y "Development Tools"
                sudo yum install -y cmake
            fi
            ;;
        arch)
            echo "检测到 Arch Linux，安装依赖..."
            sudo pacman -Syu --noconfirm
            sudo pacman -S --noconfirm base-devel cmake
            ;;
        *)
            echo "未知的 Linux 发行版，请手动安装: g++ cmake make"
            exit 1
            ;;
    esac
else
    echo "无法检测 Linux 发行版，请手动安装: g++ cmake make"
    exit 1
fi

echo "依赖安装完成!"
echo "现在可以运行: ./build.sh"